<?php include _include(APP_PATH.'view/htm/header.inc.htm');?>

<!--{hook thread_start.htm}-->

<!-- ONE开始 -->
<div class="row">
<?php if($huux_style_one['hso_col_index']==1 || $huux_style_one['hso_col_index']==2){?>
	<div class="<?php echo $col_side; ?>  hidden-md-down" id="sidebar"> 
		<!--{hook thread_user_after.htm}-->
	</div>
<?php }?>
	<div class="<?php echo $col_main; ?>">
	    <!-- 右侧开始 -->
	    <!--{hook thread_breadcrumb_before.htm}-->
		<ol class="breadcrumb m-b-sm hidden-md-down">
			<li class="breadcrumb-item"><a href="./" aria-label="<?php echo lang('index_page');?>"><i class="icon-home"></i> 首页</a></li>
			<li class="breadcrumb-item"><a href="<?php echo url("forum-$fid");?>"><?php echo $forum['name'];?></a></li>
			<li class="breadcrumb-item active"><a href="<?php echo url("thread-$tid");?>" title="正文">正文</a></li>
			<li class="pull-right"><a href="<?php echo url('thread-create-'.$fid);?>"><i class="icon-edit m-r-xs"></i><?php echo lang('thread_create_new');?></a></li>
			<!--{hook thread_breadcrumb.htm}-->
		</ol>
		<!--{hook thread_breadcrumb_after.htm}-->
		<div class="card card-content">
		    <div class="card-header">
			    <dl class="row"><dd>
						<!--{hook thread_subject_before.htm}-->
						<h3 class="break-all">
							<!--{hook thread_subject_start.htm}-->
							<?php echo $thread['subject'];?>
							<!--{hook thread_subject_end.htm}-->
						</h3>
						<!--{hook thread_subject_after.htm}-->
						<dl class="row">
							<dt>
								<!--{hook thread_username_before.htm}-->
								<span class="username m-r-xs"  data-toggle="tooltip" title="作者">
									<a class="text-muted" href="<?php echo url("user-$thread[uid]");?>"><i class="icon-user m-r-xs"></i><?php echo $thread['username'];?></a>
								</span>
								<span class="date m-r-xs" data-toggle="tooltip" title="发布时间"><i class="icon-clock-o m-r-xs"></i><?php echo $thread['create_date_fmt'];?></span>
								
								<span class="views m-r-xs hidden-md-down" data-toggle="tooltip" title="浏览数"><i class="icon-eye m-r-xs"></i><?php echo $thread['views'];?></span>
								<span class="comments m-r-xs hidden-md-down" data-toggle="tooltip" title="回复数" id="gopost2"><i class="icon-comments m-r-xs"></i><?php echo $thread['posts'];?></span>
								<!--{hook thread_views_after.htm}-->
							</dt>
							<dd class="text-right">
								<!--{hook thread_update_before.htm}-->
								<?php if($allowupdate || $first['allowupdate']) { ?>
								<a href="<?php echo url("post-update-$thread[firstpid]");?>" class="text-grey m-r-1 post_update"><i class="icon-edit"></i> <?php echo lang('edit');?></a>
								<?php } ?>
								
								<?php if($allowdelete || $first['allowdelete']) { ?>
								<a data-href="<?php echo url("post-delete-$thread[firstpid]");?>" href="javascript:void(0);" class="text-grey post_delete" isfirst="1"><i class="icon-remove"></i> <?php echo lang('delete');?></a>
								<?php } ?>
								<!--{hook thread_delete_after.htm}-->
							</dd>
						</dl>
					</dd>
				</dl>
			</div>
			<div class="card-block">
					<div class="message break-all message-reset" isfirst="1">
					
					<?php if($page == 1) { ?>
					
						<!--{hook thread_message_before.htm}-->
						<?php echo $first['message_fmt'];?>
						<!--{hook thread_message_after.htm}-->
						
						<?php echo post_file_list_html($first['filelist']);?>
						<!--{hook thread_filelist_after.htm}-->
						
					<?php } else { ?>
					
						<!--{hook thread_message_more_before.htm}-->
						<p><a href="<?php echo url("thread-$tid");?>"><?php echo lang('view_thread_message');?></a></p>
						<!--{hook thread_message_more_after.htm}-->
						
					<?php } ?>
					</div>
			</div>
			
			<?php if($huux_style_one['hso_thread_cardfooter']) { ?>
			<div class="card-footer">
			    <dl class="row">
			    <?php if($huux_style_one['hso_thread_cardfooter']==1||$huux_style_one['hso_thread_cardfooter']==2||$huux_style_one['hso_thread_cardfooter']==3) { ?>
					<dt><div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"2","bdSize":"16"},"share":{},"image":{"viewList":["qzone","tsina","tqq","renren","weixin"],"viewText":"分享到：","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["qzone","tsina","tqq","renren","weixin"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
</dt><?php }?><?php if($huux_style_one['hso_thread_cardfooter']!=3) { ?>
					<dd class="pull-right">
					<?php 
					//上下主题还得写一下
					$arrlist_n = db_find_one('thread', array('fid'=>$fid, 'tid'=>array('>'=>$tid)), array('tid'=>1));
					$arrlist_p = db_find_one('thread', array('fid'=>$fid, 'tid'=>array('<'=>$tid)), array('tid'=>-1));
					if($arrlist_p){
					   if(xn_strlen($arrlist_p['subject']) > 10){
						    $arrlist_p['subject'] = xn_substr($arrlist_p['subject'], 0, 10).'...';
						}
						echo '<a href="'.url("thread-".$arrlist_p['tid']).'" class="btn btn-secondary btn-sm m-r-xs"><i class="icon-angle-left m-r-xs"></i><span class="hidden-md-down">上一主题'.($huux_style_one['hso_thread_cardfooter']==2||$huux_style_one['hso_thread_cardfooter']==5 ? '：'.$arrlist_p['subject']:'').'</span></a>';
					}else{
						echo '<button class="btn btn-secondary btn-sm quickreply m-r-xs"><span>没了</span></button>';}
					if($arrlist_n){
					    if(xn_strlen($arrlist_n['subject']) > 10){
						    $arrlist_n['subject'] = xn_substr($arrlist_n['subject'], 0, 10).'...';
						}
						echo '<a href="'.url("thread-".$arrlist_n['tid']).'" class="btn btn-secondary btn-sm"><span class="hidden-md-down">下一主题'.($huux_style_one['hso_thread_cardfooter']==2||$huux_style_one['hso_thread_cardfooter']==5 ? '：'.$arrlist_n['subject']:'').'</span><i class="icon-angle-right m-l-xs"></i></a>';
					}else{
						echo '<button class="btn btn-secondary btn-sm m-r-xs"><span>没了</span></button>';}
					?>
					</dd>
					<?php }?>
				</dl>
			</div>
			<?php }?>

		</div>
		
		<!--{hook thread_postlist_before.htm}-->
		
		<div class="card card-post">
		    <div class="card-header">
		        <dl class="row">
					<dt>
						<b><?php echo lang('new_post');?></b> (<span class="posts"><?php echo $thread['posts'];?></span>)
					</dt>
					<dd>
						<!--{hook thread_post_list_title_right.htm}-->
					</dd>
				</dl>
		    </div>
		    <div class="card-block">
				<table class="table postlist m-b-0">
					<tbody>
					
						<?php include _include(APP_PATH.'view/htm/post_list.inc.htm'); ?>
						<tr class="post"></tr>
					</tbody>
				</table>
			</div>
			
		</div>
		
		<!--{hook thread_postlist_after.htm}-->
		
		<?php if($pagination) { ?>
		<div class="card-pagination"><nav class="text-center"><ul class="pagination m-y-xs"><?php echo $pagination; ?></ul></nav></div>
		<?php }?>
		
		<!--{hook thread_page_after.htm}-->
		
		<div class="center-block text-center card-back"><div class="btn-group" role="group" aria-label="Basic example"><a role="button" class="btn btn-secondary" href="<?php echo url("forum-$fid");?>">返回版块</a><a role="button" class="btn btn-secondary" href="./">返回首页</a>
  
  
        </div>
        </div>
	    <!-- 右侧结束 -->
	</div>
<?php if($huux_style_one['hso_col_index']==3 || $huux_style_one['hso_col_index']==4){?>
	<div class="<?php echo $col_side; ?>  hidden-md-down" id="sidebar"> 
		<!--{hook thread_user_after.htm}-->
	</div>
<?php }?>

</div>
<!-- ONE 结束 -->




<!--{hook thread_end.htm}-->

<?php include _include(APP_PATH.'view/htm/footer.inc.htm');?>

<script>

var jform = $('#quick_reply_form');
var jsubmit = $('#submit');
jform.on('submit', function() {
	jform.reset();
	jsubmit.button('loading');
	var postdata = jform.serialize();
	$.xpost(jform.attr('action'), postdata, function(code, message) {
		if(code == 0) {
			var s = '<table>'+message+'</table>';
			var jtr = $(s).find('tr');
			jtr.insertBefore($('table.postlist tr').last());
			jsubmit.button('reset');
			$('#message').val('');
			
			// 楼层 +1
			var jfloor = jform.find('.floor');
			jfloor.html(xn.intval(jfloor.html()) + 1);
			
			// 回复数 +1
			var jposts = $('.posts');
			jposts.html(xn.intval(jposts.html()) + 1);

			
			
		} else if(code < 0) {
			$.alert(message);
			jsubmit.button('reset');
		} else {
			jform.find('[name="'+code+'"]').alert(message).focus();
			jsubmit.button('reset');
		}
	});
	return false;
});

var jform2 = $('#quick_reply_form2');
var jsubmit2 = $('#submit2');
jform2.on('submit', function() {
	jform2.reset();
	jsubmit2.button('loading');
	var postdata = jform2.serialize();
	$.xpost(jform2.attr('action'), postdata, function(code, message) {
		if(code == 0) {
			var s = '<table>'+message+'</table>';
			var jtr = $(s).find('tr');
			jtr.insertBefore($('table.postlist tr').last());
			jsubmit2.button('reset');
			$('#message').val('');
			
			// 楼层 +1
			var jfloor = jform.find('.floor');
			jfloor.html(xn.intval(jfloor.html()) + 1);
			
			// 回复数 +1
			var jposts = $('.posts');
			jposts.html(xn.intval(jposts.html()) + 1);

			// 关闭模态框
			$('#oneModal').modal('hide');
			
		} else if(code < 0) {
			$.alert(message);
			jsubmit2.button('reset');
		} else {
			jform2.find('[name="'+code+'"]').alert(message).focus();
			jsubmit2.button('reset');
		}
	});
	return false;
});


// 缩放图片，适应屏幕大小。
function resize_image() {
	var jmessagelist = $('div.message');
	var first_width = jmessagelist.width(); // 815 : 746; //  734 746
	jmessagelist.each(function() {
		var jdiv = $(this);
		var maxwidth = jdiv.attr('isfirst') ? first_width : first_width - 79; //  734 746
		var jmessage_width = Math.min(jdiv.width(), maxwidth);
		jdiv.find('img, embed, iframe').each(function() {
			var jimg = $(this);
			//if(jimg.width() < 500) return;
			var img_width = this.org_width;
			var img_height = this.org_height;
			if(!img_width) {
				var img_width = jimg.width();
				var img_height = jimg.height();
				this.org_width = img_width;
				this.org_height = img_height;
			}
			//var percent = xn.min(100, xn.ceil((img_width / jmessage_width) * 100));
			if(img_width > jmessage_width) {
				if(this.tagName == 'IMG') {
					jimg.width(jmessage_width);
					jimg.css('height', 'auto');
				} else {
					jimg.width(jmessage_width);
					var height = (img_height / img_width) * jimg.width();
					jimg.height(height);
				}
			}
			
		});
	});
}
$(function() {
	resize_image();
	$(window).on('resize', resize_image);
});

// 输入框自动伸缩
var jmessage = $('.huux-message');
jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); });
jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); });

// 弹出输入框自动伸缩
var jmessage2 = $('.modal-message');
jmessage2.on('focus', function() {if(jmessage2.t) { clearTimeout(jmessage2.t); jmessage2.t = null; } jmessage2.css('height', '6rem'); });
jmessage2.on('blur', function() {jmessage2.t = setTimeout(function() { jmessage2.css('height', '2.5rem');}, 1000); });

$('#nav_pc li[fid="<?php echo $fid;?>"]').tab('show');
$('#nav_mobile li[fid="<?php echo $fid;?>"]').tab('show');






</script>

<?php if($thread['closed'] && ($gid == 0 || $gid > 5)) { ?>
<script>
jmessage.val('<?php echo lang('thread_has_already_closed');?>').attr('readonly', 'readonly');
</script>
<?php } ?>
<!--{hook thread_js.htm}-->